<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主页面</title>
<style type="text/css">
table.gridtable {
	font-family: verdana, arial, sans-serif;
	font-size: 11px;
	color: #333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}

table.gridtable th {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}

table.gridtable td {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}

tr:hover td {
	background: none;
}

tr:hover {
	background-color: none;
}

thead th {
	position: sticky;
	top: 0;
	z-index: 1;
}

table {
	border-collapse: collapse;
	width: 100%;
}

th, td {
	padding: 8px;
	text-align: left;
}

th {
	background-color: #f2f2f2;
}

#myDiv { 
	background-color: #f1f1f1;
	padding: 10px;
}
 .popup {
      width: 1000px;
      height: 700px;
      background-color: #f1f1f1;
      border: 1px solid #ccc;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    .close-btn {
      position: absolute;
      top: 0;
      right: 0;
      padding: 10px;
      cursor: pointer;
      font-size: 20px;
      color: #aaa;
    }
</style>
<meta charset="UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/grid1.0.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/echarts.min.js"></script>
</head> 
<body>

 
		<button id="button_17">今日涨停方向分析</button><button id="bt6_1">今日涨停最近原因分析</button><button id="bt6_2">今日涨停概念分析</button>
		<div id="div2-3"></div>
		<div id="div2-4"></div>
	<div id="div1"></div>
	<div id="myDiv"></div>
	<div class="popup" style="display:none;overflow-y:auto; ">
<!-- 这里可以添加你的内容 --> <span class="close-btn" id="san1">×</span>
   <div style="width:1000px;height:800px;margin-top: 40px;" id="mainechar">
   
   </div>
 
	 </div>
	 
<script type="text/javascript">

(function(){
	$("#button_17").click(function(){
		 
		aaa();
	});
	
	 
	
	function aaa(){
		var text17 = $("#text17").val(); 
		 $.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/getJinriFenxi",
				dataType : 'text', 
				data:{text17:$("#text17").val(),text18:$("#text18").val(),text19:$("#text19").val()},
				success : function(msg) { 
					$("#myDiv").html(msg);
					$("#mytalbe").addClass("gridtable"); 
					tongyong();
					 $('table tbody tr').sort(function(a, b) {
					        return parseFloat($('td[name=xiaying]', b).text()) - parseFloat($('td[name=xiaying]', a).text());
					  }).appendTo('table tbody');
					 
				} 
			}); 
	}
	function tongyong(){
		
	 
		 $("#mytalbe td[name=cjje]:not(:first)").each(function(){ 
			 var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $("#mytalbe td[name=xiaying]:not(:first)").each(function(){ 
			 var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $("#mytalbe td[name=shizhi]:not(:first)").each(function(){
		        var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $("#mytalbe td[name=ji20min]:not(:first)").each(function(){
		        var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $("#mytalbe td[name=liangbi]:not(:first)").each(function(){
		        var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $("#mytalbe td[name=table_id]").each(function(){ 
		        $(this).hide();
		 });
		 $("#mytalbe td[name=lt]").each(function(){ 
		        $(this).hide();
		 });
		 $("#mytalbe td[name=createTime]").each(function(){ 
		        $(this).hide();
		 });
		 $("#mytalbe td[name=cjllist]").each(function(){ 
		        $(this).hide();
		 });
		 $("#mytalbe td[name=qy]").each(function(){ 
		        $(this).hide();
		 });
		 $("#mytalbe td[name=jgbi]:not(:first)").each(function(){ 
			 var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $("td[name='zhangdiefu']:not(:first)").each(function () {
		        var value = parseFloat($(this).text());
		        if (!isNaN(value)) {
		            if (value >= 0) {
		                $(this).css('color','red');
		            } else {
		                $(this).css('color', 'green');
		            }
		        }
		    });
		 $("#mytalbe td[name=cjlsum]:not(:first)").each(function(){ 
			 var num = parseFloat($(this).text()); 
		        var roundedNum = num.toFixed(2);
		        $(this).text(roundedNum);
		 });
		 $('#mytalbe').each(function() {
			  var rows = $(this).find('tr:not(:first)');
			  rows.sort(function(a, b) {
			    var aValue = $(a).find('td[name=ji20min]').text();
			    var bValue = $(b).find('td[name=ji20min]').text();
			    return aValue.localeCompare(bValue);
			  });
			  $(this).append(rows);
			});
		 
		 $('table tbody tr').sort(function(a, b) {
		        return parseInt($('td[name=cjlsum]', b).text()) - parseInt($('td[name=cjlsum]', a).text());
		    }).appendTo('table tbody');
		 $('table tbody tr').sort(function(a, b) {
		        return parseInt($('td[name=cjje]', b).text()) - parseInt($('td[name=cjje]', a).text());
		  }).appendTo('table tbody');
		 
		 
	}
	$("#bt6_1").click(function(){
	 
		$("#div2-3").html("");
		var list = $("td[name=ztContent]"); 
		var arrall = [];
	 
		for (var i = 0; i < list.length; i++) { 
			//debugger;
			var text = $(list[i]).text(); 
		     arr1  =text.split("+"); 
		     for(var j=0;j<arr1.length;j++){
		    	 if(arr1[j]==""){
		    		 continue;
		    	 }
		    	 arrall.push($.trim(arr1[j]));
		     }
		}
		// console.log(arrall);
		 var countMap = {};
		 for (var i = 0; i < arrall.length; i++) {
		   var num = arrall[i];
		   if (countMap[num]) {
		     countMap[num]++;
		   } else {
		     countMap[num] = 1;
		   }
		 }
		 console.log(countMap); 
		 var sortedCountMap = Object.entries(countMap).sort((a, b) => b[1] - a[1]);
		 var i=0;
		 for (var [num, count] of sortedCountMap) {
		     i++;
		   console.log(num + ": " + count);
		   $("#div2-3").append("<lable>"+num+"("+count+")"+"</lable>");
		   if(i>20){
			   break;
		   }
		 } 
		 $("#div2-3").children().click(function(){
			 var value = $(this).text();
			 value = value.replace(/\d+/g, '');
			 value = value.replace('(','');
			 value = value.replace(')','');
				var list = $("td[name=ztContent]");
				for (var i = 0; i < list.length; i++) {
					var text =$(list[i]).text();
					debugger;
				    if(text.length<=0){
				    	$(list[i]).parent().hide();
				    	continue;
				    }
					if(text.indexOf(value) >=0){
						$(list[i]).parent().show();
					}else{
						$(list[i]).parent().hide();
					} 
					
				}
		 });
		
	});
	
	
	$("#bt6_2").click(function(){
		 
		$("#div2-4").html("");
		var list = $("td[name=gn]"); 
		var arrall = [];
	 
		for (var i = 0; i < list.length; i++) { 
			//debugger;
			var text = $(list[i]).text(); 
		     arr1  =text.split("+"); 
		     for(var j=0;j<arr1.length;j++){
		    	 if(arr1[j]==""){
		    		 continue;
		    	 }
		    	 arrall.push($.trim(arr1[j]));
		     }
		}
		// console.log(arrall);
		 var countMap = {};
		 for (var i = 0; i < arrall.length; i++) {
		   var num = arrall[i];
		   if (countMap[num]) {
		     countMap[num]++;
		   } else {
		     countMap[num] = 1;
		   }
		 }
		 console.log(countMap); 
		 var sortedCountMap = Object.entries(countMap).sort((a, b) => b[1] - a[1]);
		 var i=0;
		 for (var [num, count] of sortedCountMap) {
		     i++;
		   console.log(num + ": " + count);
		   $("#div2-4").append("<lable>"+num+"("+count+")"+"</lable>");
		   if(i>20){
			   break;
		   }
		 } 
		 $("#div2-4").children().click(function(){
			 var value = $(this).text();
			 value = value.replace(/\d+/g, '');
			 value = value.replace('(','');
			 value = value.replace(')','');
				var list = $("td[name=gn]");
				for (var i = 0; i < list.length; i++) {
					var text =$(list[i]).text();
					debugger;
				    if(text.length<=0){
				    	$(list[i]).parent().hide();
				    	continue;
				    }
					if(text.indexOf(value) >=0){
						$(list[i]).parent().show();
					}else{
						$(list[i]).parent().hide();
					} 
					
				}
		 });
		
	});
	
	
	 
})();
</script>
</body>
</html>